package com.example.jl.bethinner.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.jl.bethinner.R;
import com.example.jl.bethinner.domain.City;
import com.example.jl.bethinner.util.ViewHolder;

import java.util.List;

/**
 * Created by JL on 8/7/15.
 */
public class HELCityChooserAdapter extends BaseAdapter {
    private Context context;
    private List<City> cities;


    public HELCityChooserAdapter(Context context, List<City> cities) {
        this.context = context;
        this.cities = cities;
    }


    @Override
    public int getCount() {
        return cities.size();
    }

    @Override
    public String getItem(int position) {
        return cities.get(position).getCityid();
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null)
            convertView = LayoutInflater.from(context).inflate(R.layout.itme_city_chooser, parent, false);
        TextView city_name = ViewHolder.get(convertView, R.id.city);
        city_name.setText(cities.get(position).getCity());
        return convertView;
    }
}
